<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {

        }
        .container {
            perspective: 1000px;
            margin: 100px auto;
            /* overflow: hidden; */
            width: 200px;
        }
        .left,
        .right {
            width: 100px;
            height: 150px;
            float: left;
            transition: transform 1s ease;
        }
        .left {
            background-color: red;
            transform-origin: right;
        }
        .right {
            background-color: green;
            transform-origin: left;
        }

        .container:hover .left {
            transform: rotateY(45deg);
        }
        .container:hover .right {
            transform: rotateY(-45deg);
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="left"></div>
        <div class="right"></div>
    </div>
</body>
</html>